package thread.threadpool.example2;


/**
 * @Description: 线程实现类1  执行任务时打印当前线程和任务id
 * @date: 2023/1/30 11:45
 * @author: Huangjunjie
 * @since JDK 1.8
*/
public class MyRunnable implements Runnable {

    private final int id;

    public MyRunnable(int id) {
        this.id = id;
    }

    @Override
    public void run() {
//        try {
//            Thread.sleep(100);
//        } catch (InterruptedException e) {
//            throw new RuntimeException(e);
//        }
        System.out.println(Thread.currentThread().getName() + "：执行任务id：" + id);
    }

    @Override
    public String toString() {
        return "MyRunnable{" +
                "id=" + id +
                '}';
    }
}
